import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import java.rmi.RemoteException;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JTable;


public class UpdateUserDialog extends JDialog {
	private JTable tblUserList;
	private JTextField txtUserID;
	private JTextField txtNameofUser;
	private JTextField txtPassword;
	private JLabel lblName;
	private JButton btnCancel;
	private JLabel lblUserid;
	private JLabel lblUpdateNewUser;
	private JLabel lblPassword;
	private JLabel lblUserType;
	private JButton btnOk;
	private JComboBox comboBox;
	
	AccessDBInterface accClientThis;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			UpdateUserDialog dialog = new UpdateUserDialog(null, 0);
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public UpdateUserDialog(AccessDBInterface accClient, int numberofservers) {
		
		accClientThis = accClient;
		
		setBounds(100, 100, 450, 433);
		getContentPane().setLayout(null);
		{
			lblUpdateNewUser = new JLabel("UPDATE USER");
			lblUpdateNewUser.setHorizontalAlignment(SwingConstants.CENTER);
			lblUpdateNewUser.setFont(new Font("Tahoma", Font.BOLD, 20));
			lblUpdateNewUser.setBounds(143, 11, 160, 14);
			getContentPane().add(lblUpdateNewUser);
		}
		
		tblUserList = new JTable();
		tblUserList.setBounds(57, 173, 308, -115);
		getContentPane().add(tblUserList);
		
		lblUserid = new JLabel("UserID");
		lblUserid.setBounds(57, 213, 46, 14);
		getContentPane().add(lblUserid);
		
		txtUserID = new JTextField();
		txtUserID.setEditable(false);
		txtUserID.setBounds(149, 207, 240, 20);
		getContentPane().add(txtUserID);
		txtUserID.setColumns(10);
		
		lblName = new JLabel("Name");
		lblName.setBounds(57, 249, 46, 14);
		getContentPane().add(lblName);
		
		txtNameofUser = new JTextField();
		txtNameofUser.setBounds(149, 243, 240, 20);
		getContentPane().add(txtNameofUser);
		txtNameofUser.setColumns(10);
		
		lblUserType = new JLabel("User Type");
		lblUserType.setBounds(57, 285, 72, 14);
		getContentPane().add(lblUserType);
		
		comboBox = new JComboBox();
		comboBox.setBounds(149, 282, 240, 20);
		getContentPane().add(comboBox);
		
		lblPassword = new JLabel("Password");
		lblPassword.setBounds(57, 318, 72, 14);
		getContentPane().add(lblPassword);
		
		txtPassword = new JTextField();
		txtPassword.setBounds(149, 315, 240, 20);
		getContentPane().add(txtPassword);
		txtPassword.setColumns(10);
		
		btnOk = new JButton("OK");
		btnOk.setBounds(82, 361, 89, 23);
		getContentPane().add(btnOk);
		
		btnCancel = new JButton("Cancel");
		btnCancel.setBounds(247, 361, 89, 23);
		getContentPane().add(btnCancel);
		
		try {
			ResultSet rs = accClientThis.GetTable("User");
			tblUserList.setModel(new rsTableModel(rs));
		} catch (RemoteException | SQLException e) {
			// TODO Auto-generated catch block
			JOptionPane.showMessageDialog(null, e.toString());
		}
	}
	public JLabel getLblName() {
		return lblName;
	}
	public JButton getBtnCancel() {
		return btnCancel;
	}
	public JLabel getLblUserid() {
		return lblUserid;
	}
	public JTable getTblUserList() {
		return tblUserList;
	}
	public JTextField getTxtPassword() {
		return txtPassword;
	}
	public JLabel getLblUpdateNewUser() {
		return lblUpdateNewUser;
	}
	public JLabel getLblPassword() {
		return lblPassword;
	}
	public JLabel getLblUserType() {
		return lblUserType;
	}
	public JTextField getTxtUserID() {
		return txtUserID;
	}
	public JButton getBtnOk() {
		return btnOk;
	}
	public JComboBox getComboBox() {
		return comboBox;
	}
	public JTextField getTxtNameofUser() {
		return txtNameofUser;
	}
}
